package cn.ydt.ydt.community.webapi.controller;

import cn.ydt.ydt.common.resful.JsonResult;
import cn.ydt.ydt.community.service.INucleicAcidTestAppointService;
import cn.ydt.ydt.pojo.community.dto.NucleicAcidTestAppointmentDTO;
import cn.ydt.ydt.pojo.community.vo.SelectNucleicTestResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/ydt/ydt-nucleic_acid_test_appointment")
@Api(tags = "核酸检测模块")
@Slf4j
public class NucleicAcidTestAppointmentController {

    @Autowired
    private INucleicAcidTestAppointService appointIdService;

    @PostMapping("/appointment")
    @ApiOperation(value = "核酸检测预约的方法")
    public JsonResult<Void> appointment(@Validated @RequestBody NucleicAcidTestAppointmentDTO nucleicAcidTestAppointmentDTO){

//        Date date = nucleicAcidTestAppointmentDTO.getNucleicAcidTestAppointmentTime();
//        TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
//        nucleicAcidTestAppointmentDTO.setNucleicAcidTestAppointmentTime(date);

        log.info("---" +
                "nucleicAcidTestAppointmentIdDTO:{}", nucleicAcidTestAppointmentDTO);
        appointIdService.appointment(nucleicAcidTestAppointmentDTO);
        return JsonResult.ok("成功");
    }

    @GetMapping("/select")
    @ApiOperation(value = "核酸结果查询的方法")
    public JsonResult  selectResult(){
        List<SelectNucleicTestResultVO> selectNucleicTestResultVOS = appointIdService.selectResult();
        return JsonResult.ok(selectNucleicTestResultVOS);

    }

    @GetMapping("/select/all")
    @ApiOperation(value = "所有核酸结果查询的方法")
    public JsonResult  selectAllResult(){

        log.info("查询的用户id:{}" );
        List<SelectNucleicTestResultVO> selectNucleicTestResultVOS = appointIdService.selectAllResult();
        return JsonResult.ok(selectNucleicTestResultVOS);

    }

}
         